/**
 * @author Richard Stauffer
 */
package com.example.noelwhereismystuffs.models;

import java.io.Serializable;

import android.util.Log;

public class User implements Serializable {

	private static final long serialVersionUID = 1L;
	private boolean isAdmin = false;
	private String username;
	private String email;
	private String password;
	private String location;
	private boolean isLocked;
	private int loginAttempts;
	public static final User NULL_USER = new User("", "", "");

	public User(String email, String password) {
		this.email = email;
		this.password = password;
	}

	public User(String username, String email, String password) {
		this.username = username;
		this.email = email;
		this.password = password;
	}

	/**
	 * @return the username
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * @param username
	 *            the username to set
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param email
	 *            the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the isUnlocked
	 */
	public boolean isLocked() {
		return isLocked;
	}

	/**
	 * Lock the user
	 */
	public void lock() {
		this.isLocked = true;
	}
	
	/**
	 * Unlock the user
	 */
	public void unlock(){
		Log.d("User", "Unlock user");
		loginAttempts = 0;
		this.isLocked = false;
	}

	/**
	 * @return the loginAttempts
	 */
	public int getLoginAttempts() {
		return loginAttempts;
	}

	/**
	 * @param loginAttempts
	 *            the loginAttempts to set
	 */
	public void setLoginAttempts(int loginAttempts) {
		this.loginAttempts = loginAttempts;
	}

	/**
	 * 
	 * @param password
	 * @return
	 */
	public boolean verify(String password) {
		if (password.equals(this.password) && !isLocked)
			return true;
		else {
			loginAttempts++;
			return false;
		}
	}

	/**
	 * Check is this User an Admin
	 * @return 
	 */

	public boolean isAdmin() {
		return isAdmin;
	}
	
	/**
	 * Set this user to be an Admin
	 */
	public void setAdmin(){
		isAdmin = true;
	}
	
	
}
